from time import sleep

from selenium import webdriver
from selenium.webdriver.common.by import By

chrome_location = r'E:\nmon\light_Chrome\chrome-win\chrome.exe'
options = webdriver.ChromeOptions()
options.binary_location=chrome_location

driver = webdriver.Chrome(options=options)
url = r'https://www.baidu.com'
driver.get(url)
driver.maximize_window()

try:
    ele = driver.find_element(By.LINK_TEXT, 'hao1235')
except Exception as e:
    print('没有新闻')
    print(driver.title)
else:
    ele.click()
    sleep(3)
    print('有新闻')
finally:
    print('你可真是个小机灵鬼！')